<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="../css/docs.css" type="text/css" rel="stylesheet" />
<link href="../css/prettify.css" type="text/css" rel="stylesheet" />
<script src="../js/prettify.js" type="text/javascript"></script>
</head>
<body onLoad="prettyPrint()">
<div class="g-unit" id="doc-content">
<div id="api-info-block">
<div class="api-level">H3C CAS云管理平台</div>
</div>
<div id="jd-header">
<h1>创建虚拟交换机</h1>
</div>
<div id="jd-content">
<div class="jd-descr">
<p>创建虚拟交换机。</p>
<h2><a name="uri"></a>接口 URI</h2>
<p>/cas/casrs/vswitch</p>
<h2><a name="access"></a>访问方法</h2>
<dl>
  <dt><b>HTTP 方法</b></dt>
  <dd>POST</dd>
  <dt><b>消息体</b></dt>
  <div class="source">
  	<pre class="prettyprint lang-xml">&lt;vSwitch&gt;<br>	&lt;name&gt;vswitch0&lt;/name&gt;<br>	&lt;hostId&gt;2&lt;/hostId&gt;<br>	&lt;portNum&gt;32&lt;/portNum&gt;<br>	&lt;mode&gt;0&lt;/mode&gt;<br>	&lt;pnic&gt;eth0&lt;/pnic&gt;<br>	&lt;status&gt;1&lt;/status&gt;<br>	&lt;address&gt;192.168.0.8&lt;/address&gt;<br>	&lt;netmask&gt;255.255.255.0&lt;/netmask&gt;<br>	&lt;gateway&gt;192.168.0.1&lt;/gateway&gt;<br>	&lt;enableLacp&gt;false&lt;/enableLacp&gt;<br>	&lt;bondMode&gt;balance-tcp&lt;/bondMode&gt;<br>	&lt;description&gt;test vswitch&lt;/description&gt;<br>	&lt;vlanId&gt;6&lt;/vlanId&gt;
	&lt;enableDpdk&gt;false&lt;/enableDpdk&gt;<br>&lt;/vSwitch&gt;</pre>
  </div>
</dl>
<dt><a name="detail"></a><b>元素含义</b></dt>
<table class="jd-sumtable" id="pubmethods">
  <tbody>
    <tr>
      <th colspan="2"><span class="prettyprint lang-xml">vSwitch</span>各子元素</th>
	<tr>
      <td class="jd-typecol"><span class="prettyprint lang-xml">name</span></td>
      <td class="jd-linkcol" width="100%"><span class="sympad">虚拟交换机名称。</span>
          <div class="jd-descrdiv">字符串（String）类型。</div></td>
    </tr>
    <tr class="alt-color">
      <td class="jd-typecol"><span class="prettyprint lang-xml">hostId</span></td>
      <td class="jd-linkcol" width="100%"><span class="sympad">主机id。</span>
          <div class="jd-descrdiv">整数（int）类型。</div></td>
    </tr>
	<tr>
      <td class="jd-typecol"><span class="prettyprint lang-xml">portNum</span></td>
      <td class="jd-linkcol" width="100%"><span class="sympad">端口数量。</span>
          <div class="jd-descrdiv">整数（int）类型。</div></td>
    </tr>
    <tr class="alt-color">
      <td class="jd-typecol"><span class="prettyprint lang-xml">mode</span></td>
      <td class="jd-linkcol" width="100%"><span class="sympad">转发模式。0 : veb; 1: vepa; 2:多通道。</span>
          <div class="jd-descrdiv">整数（int）类型。</div></td>
    </tr>
	<tr>
      <td class="jd-typecol"><span class="prettyprint lang-xml">pnic</span></td>
      <td class="jd-linkcol" width="100%"><span class="sympad">vSwitch绑定的所有物理网卡名。可以为多个，用英文的逗号分隔，如</span>
          &lt;pnic&gt;eth0,eth1&lt;pnic&gt;
            <div class="jd-descrdiv">字符串（String）类型。</div></td>
    </tr>
    <tr class="alt-color">
      <td class="jd-typecol"><span class="prettyprint lang-xml">status</span></td>
      <td class="jd-linkcol" width="100%"><span class="sympad">虚拟机交换状态。0:不活动 1:活动。</span>
          <div class="jd-descrdiv">整数（int）类型。</div></td>
    </tr>
 	<tr>
      <td class="jd-typecol"><span class="prettyprint lang-xml">address</span></td>
      <td class="jd-linkcol" width="100%"><span class="sympad">IP地址。</span>
          <div class="jd-descrdiv">字符串（String）类型。</div></td>
    </tr>
    <tr class="alt-color">
      <td class="jd-typecol"><span class="prettyprint lang-xml">netmask</span></td>
      <td class="jd-linkcol" width="100%"><span class="sympad">网络掩码。</span>
          <div class="jd-descrdiv">字符串（String）类型。</div></td>
    </tr>
	<tr>
      <td class="jd-typecol"><span class="prettyprint lang-xml">gateway</span></td>
      <td class="jd-linkcol" width="100%"><span class="sympad">网关。</span>
          <div class="jd-descrdiv">字符串（String）类型。</div></td>
    </tr>
    <tr class="alt-color">
      <td class="jd-typecol"><span class="prettyprint lang-xml">enableLacp</span></td>
      <td class="jd-linkcol" width="100%"><span class="sympad">链路聚合模式(动态链路聚合：true，静态链路聚合：false。)</span>
        <div class="jd-descrdiv">布尔（Boolean）类型。</div></td></tr>
	<tr>
      <td class="jd-typecol"><span class="prettyprint lang-xml">bondMode</span></td>
      <td class="jd-linkcol" width="100%"><span class="sympad">负载分担模式。枚举类型，启用lacp:balance-slb ，balance-tcp；不启用lacp:balance-slb ，balance-tcp, active-backup。 <br/>
	  balance-slb : 基本负载分担,balance-tcp : 高级负载分担,active-backup : 主备负载分担
</span>
          <div class="jd-descrdiv">字符串（String）类型。</div></td>
    </tr>
	<tr class="alt-color">
      <td class="jd-typecol"><span class="prettyprint lang-xml">description</span></td>
      <td class="jd-linkcol" width="100%"><span class="sympad">描述信息。</span>
          <div class="jd-descrdiv">字符串（String）类型。</div></td>
    </tr>
	<tr>
      <td class="jd-typecol"><span class="prettyprint lang-xml">vlanId</span></td>
      <td class="jd-linkcol" width="100%"><span class="sympad">VLAN ID。虚拟交换机端口所在<span lang="EN-US">VLAN</span>的<span lang="EN-US">ID</span>。<span lang="EN-US">VLAN ID</span>的取值范围为<span lang="EN-US">2</span>～<span lang="EN-US">4094</span>。</span>
          <div class="jd-descrdiv">整数（int）类型。</div></td>
    </tr>
	<tr class="alt-color">
      <td class="jd-typecol"><span class="prettyprint lang-xml">enableDpdk</span></td>
	  <td class="jd-linkcol"><span class="sympad">是否启用DPDK(启用：true，不启用：false)</span>
          <div class="jd-descrdiv">布尔（Boolean）类型。</div></td>
	  </tr>

</table>

<h2><a name="result"></a>返回结果</h2>
<dl>
  <dt><b>状态码</b></dt>
  <dd>
  <ul>
    <li>200(OK)：成功。</li>
  </ul>
  </dd>
  <dt><b>消息头</b></dt>
  <br>
  <pre class="prettyprint lang-xml">
HTTP/1.1 200 OK
vsId:{vswtichId}
Content-Type: application/xml<br>Transfer-Encoding: chunked<br>Date: Tue, 16 Sep 2014 09:16:07 GMT
</pre>
</dl>

<p><b>消息体</b></p>
<dl>
  <div class="source">
    <pre class="prettyprint lang-xml">112</pre>
  </div>
</dl>
<p><a name="detail"></a><b>元素含义</b></p>
<table id="pubmethods" class="jd-sumtable">
  <tbody>
    <tr>
      <th colspan="2">返回创建虚拟交换机id。</th>
    </tr>
</table>
<p>&nbsp;</p>
<h2><a name="example"></a>应用举例</h2>
    <p>1.在id为2的主机上增加虚拟交换机。</p>
    <dl>
      <dt><b>请求</b></dt>
      <div class="source">
        <pre class="prettyprint lang-xml">POST http://localhost:8080/cas/casrs/vswitch
accept: application/xml
&lt;vSwitch&gt;<br>	&lt;name&gt;vswitch0&lt;/name&gt;<br>	&lt;hostId&gt;2&lt;/hostId&gt;<br>	&lt;portNum&gt;32&lt;/portNum&gt;<br>	&lt;mode&gt;0&lt;/mode&gt;<br>	&lt;pnic&gt;eth0&lt;/pnic&gt;<br>	&lt;status&gt;1&lt;/status&gt;<br>	&lt;address&gt;192.168.0.8&lt;/address&gt;<br>	&lt;netmask&gt;255.255.255.0&lt;/netmask&gt;<br>	&lt;gateway&gt;192.168.0.1&lt;/gateway&gt;<br>	&lt;enableLacp&gt;false&lt;/enableLacp&gt;<br>	&lt;bondMode&gt;balance-tcp&lt;/bondMode&gt;<br>	&lt;description&gt;test vswitch&lt;/description&gt;<br>	&lt;vlanId&gt;6&lt;/vlanId&gt; 
	&lt;enableDpdk&gt;false&lt;/enableDpdk&gt;<br>&lt;/vSwitch&gt;</pre>
      </div>
      <dt><b>回应</b></dt>
      <div class="source">
        <pre class="prettyprint lang-xml">HTTP/1.1 200 OK

vsId:{vswtichId}
Content-Type: application/xml<br>Transfer-Encoding: chunked<br>Date: Tue, 16 Sep 2014 09:16:07 GMT
...<br>112<br></pre>
      </div>
    </dl>
	
	    <p>2.在id为6的主机上增加DPDK虚拟交换机。</p>
        <dl>
      <dt><b>请求</b></dt>
      <div class="source">
        <pre class="prettyprint lang-xml">POST http://localhost:8080/cas/casrs/vswitch
accept: application/xml
&lt;vSwitch&gt;<br>	&lt;name&gt;testDPDK&lt;/name&gt;<br>	&lt;hostId&gt;6&lt;/hostId&gt;<br>	&lt;portNum&gt;32&lt;/portNum&gt;<br>	&lt;mode&gt;0&lt;/mode&gt;<br>	&lt;pnic&gt;pci_04_00_1&lt;/pnic&gt;<br>	&lt;status&gt;1&lt;/status&gt;<br>	&lt;address&gt;12.23.45.56&lt;/address&gt;<br>	&lt;netmask&gt;255.255.0.0&lt;/netmask&gt;<br>	&lt;enableLacp&gt;false&lt;/enableLacp&gt;<br>	&lt;bondMode&gt;balance-tcp&lt;/bondMode&gt;<br>	&lt;description&gt;test vswitch&lt;/description&gt;<br>	&lt;vlanId&gt;6&lt;/vlanId&gt;<br>	&lt;enableDpdk&gt;true&lt;/enableDpdk&gt;<br>&lt;/vSwitch&gt;</pre>
      </div>
      <dt><b>回应</b></dt>
      <div class="source">
        <pre class="prettyprint lang-xml">HTTP/1.1 200 OK

vsId:{vswtichId}
Content-Type: application/xml<br>Transfer-Encoding: chunked<br>Date: Tue, 16 Sep 2014 09:16:07 GMT
...<br>151<br></pre>
      </div>
    </dl>

</div>
</div>
</div>
</body>
</html>